package com.jihui.enterprise.web.controller;

import com.jihui.account.AbcUser;
import com.jihui.enterprise.AbcEnterprise;
import com.jihui.enterprise.EnterpriseManager;
import com.jihui.enterprise.web.document.DocumentationConstants;
import lombok.extern.slf4j.Slf4j;
import org.jsondoc.core.annotation.Api;
import org.jsondoc.core.annotation.ApiMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.web.authentication.RememberMeServices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * user login
 *
 * @author linux_china
 */
@RestController
@RequestMapping
@Slf4j
@Api(description = "登录服务", name = "web", group = DocumentationConstants.GROUP_Account)
public class TestController{
    /**
     * 设置cookie的作用域名
     */
    @Value("${info.domain}")
    private String domain;

    @Value("${info.buyer.domain}")
    private String buyerDomain;
    @Value("${info.seller.mall.domain}")
    private String sellerMallDomain;
    @Value("${info.seller.special.domain}")
    private String sellerSpecialDomain;
    @Value("${info.seller.domain}")
    private String sellerDomain;
    @Value("${info.crm.domain}")
    private String crmDomain;
    @Value("${info.cms.domain}")
    private String cmsDomain;


    @Autowired
    private EnterpriseManager enterpriseManager;
    @Autowired
    private CounterService counterService;
    @Autowired
    private RememberMeServices rememberMeServices;

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @ApiMethod(id = "login_index", description = "登录首页", summary = "login index")
    public AbcEnterprise loginPage(@AuthenticationPrincipal AbcUser account) {
        AbcEnterprise enterprise = enterpriseManager.findByUserId(account.getUserId());
        System.out.println(1);
        return enterprise;
    }


}
